package com.haoshuang.zhouzhoubang.ui.dialog

import android.content.Context

import android.widget.LinearLayout
import android.widget.TextView
import com.blankj.utilcode.util.SnackbarUtils.dismiss
import com.haoshuang.zhouzhoubang.R
import com.lxj.xpopup.core.BottomPopupView


import com.mufeng.libs.utils.view.clickWithTrigger
import com.mufeng.libs.utils.view.gone
import com.mufeng.libs.utils.view.visible


class OrderDialog(
    context: Context,
    str: String,
    str2: String,
    private val paid: Int?,
    private val onSubmit: (str: Int) -> Unit
) : BottomPopupView(context) {
    override fun getImplLayoutId(): Int = R.layout.dialog_order
    var str11 = str
    var str12 = str2
    override fun initPopupContent() {
        super.initPopupContent()


        var tvCommit = findViewById<TextView>(R.id.tvCommit)
        var tvPrice2 = findViewById<TextView>(R.id.tvPrice2)
        var tvPrice = findViewById<TextView>(R.id.tvPrice)
        var tvGb = findViewById<TextView>(R.id.tvGb)
        var llEw = findViewById<LinearLayout>(R.id.llEw)
        var tvPayStatus = findViewById<TextView>(R.id.tvPayStatus)

        if (paid != 1) {
            tvPayStatus.setBackgroundResource(R.drawable.bg_2lan)
            tvPayStatus.text = "未支付"
        } else {
            tvPayStatus.text = "已支付"
            tvPayStatus.setBackgroundResource(R.drawable.bg_2red)
        }

        tvPrice.text = "¥" + str11
        if (str12.isNullOrBlank()) {
            llEw.gone()
        } else {
            llEw.visible()
        }
        tvPrice2.text = "¥" + str12
        tvGb.clickWithTrigger {
            dismiss()
        }
        tvCommit.setOnClickListener {
            dismiss()
            onSubmit(1)
        }
    }


}